home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / texinfo / info / signals.h < prev    next >
C/C++ Source or Header  |  1994-01-28  |  3KB  |  86 lines

  1. /* signals.h -- Header to include system dependent signal definitions. */
  2.  
  3. /* This file is part of GNU Info, a program for reading online documentation
  4.    stored in Info format.
  5.  
  6.    Copyright (C) 1993 Free Software Foundation, Inc.
  7.  
  8.    This program is free software; you can redistribute it and/or modify
  9.    it under the terms of the GNU General Public License as published by
  10.    the Free Software Foundation; either version 2, or (at your option)
  11.    any later version.
  12.  
  13.    This program is distributed in the hope that it will be useful,
  14.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.    GNU General Public License for more details.
  17.  
  18.    You should have received a copy of the GNU General Public License
  19.    along with this program; if not, write to the Free Software
  20.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22.    Written by Brian Fox (bfox@ai.mit.edu). */
  23.  
  24. #if !defined (_SIGNALS_H_)
  25. #define _SIGNALS_H_
  26.  
  27. #include <signal.h>
  28.  
  29. #define HAVE_SIGSETMASK
  30.  
  31. #if !defined (_POSIX_VERSION) && !defined (sigmask)
  32. #  define sigmask(x) (1 << ((x)-1))
  33. #endif /* !POSIX && !sigmask */
  34.  
  35. #if !defined (_POSIX_VERSION)
  36. #  if !defined (SIG_BLOCK)
  37. #    define SIG_UNBLOCK 1
  38. #    define SIG_BLOCK   2
  39. #    define SIG_SETMASK 3
  40. #  endif /* SIG_BLOCK */
  41.  
  42. /* Type of a signal set. */
  43. #  define sigset_t int
  44.  
  45. /* Make SET have no signals in it. */
  46. #  define sigemptyset(set) (*(set) = (sigset_t)0x0)
  47.  
  48. /* Make SET have the full range of signal specifications possible. */
  49. #  define sigfillset(set) (*(set) = (sigset_t)0xffffffffff)
  50.  
  51. /* Add SIG to the contents of SET. */
  52. #  define sigaddset(set, sig) *(set) |= sigmask (sig)
  53.  
  54. /* Delete SIG from the contents of SET. */
  55. #  define sigdelset(set, sig) *(set) &= ~(sigmask (sig))
  56.  
  57. /* Tell if SET contains SIG. */
  58. #  define sigismember(set, sig) (*(set) & (sigmask (sig)))
  59.  
  60. /* Suspend the process until the reception of one of the signals
  61.    not present in SET. */
  62. #  define sigsuspend(set) sigpause (*(set))
  63. #endif /* !_POSIX_VERSION */
  64.  
  65. /* These definitions are used both in POSIX and non-POSIX implementations. */
  66.  
  67. #define BLOCK_SIGNAL(sig) \
  68.   do { \
  69.     sigset_t nvar, ovar; \
  70.     sigemptyset (&nvar); \
  71.     sigemptyset (&ovar); \
  72.     sigaddset (&nvar, sig); \
  73.     sigprocmask (SIG_BLOCK, &nvar, &ovar); \
  74.   } while (0)
  75.  
  76. #define UNBLOCK_SIGNAL(sig) \
  77.   do { \
  78.     sigset_t nvar, ovar; \
  79.     sigemptyset (&ovar); \
  80.     sigemptyset (&nvar); \
  81.     sigaddset (&nvar, sig); \
  82.     sigprocmask (SIG_UNBLOCK, &nvar, &ovar); \
  83.   } while (0)
  84.  
  85. #endif /* !_SIGNALS_H_ */
  86.